package homework;

import java.util.Scanner;

public class Hollow_Square {
    public static void main(String[] args) {
        //打印正方形，用户输入正方形边长，用*打印出空心正方形。
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入所要打印正方形的边长");
        int Side_length = sc.nextInt();

        for (int i = 0; i < Side_length; i++) {
            if (i > 0 && i < Side_length-1){    //中间空的情况
                for (int j = 0; j < Side_length; j++) {     //竖列
                    if (j == 0 | j == Side_length-1){       //第一列和最后一列
                        System.out.print("* ");
                    }else if (j <= Side_length-1) {         //中间空列
                        System.out.print("  ");
                    }
                }
            }else if (i == 0 | i == Side_length-1) {        //第一行和最后一行
                for (int k = 0; k < Side_length; k++){
                    System.out.print("* ");
                }
            }
            System.out.println("  ");
        }
    }

}
